export namespace types {
	
	export class Type {
	    type?: string;
	    prec?: number;
	    scale?: number;
	    nullable?: boolean;
	    array?: boolean;
	    unsigned?: boolean;
	
	    static createFrom(source: any = {}) {
	        return new Type(source);
	    }
	
	    constructor(source: any = {}) {
	        if ('string' === typeof source) source = JSON.parse(source);
	        this.type = source["type"];
	        this.prec = source["prec"];
	        this.scale = source["scale"];
	        this.nullable = source["nullable"];
	        this.array = source["array"];
	        this.unsigned = source["unsigned"];
	    }
	}
	export class Field {
	    name?: string;
	    datatype?: Type;
	    default?: string;
	    is_primary?: boolean;
	    is_sequence?: boolean;
	    const_value?: number;
	    interpolate?: boolean;
	    join?: boolean;
	    comment?: string;
	
	    static createFrom(source: any = {}) {
	        return new Field(source);
	    }
	
	    constructor(source: any = {}) {
	        if ('string' === typeof source) source = JSON.parse(source);
	        this.name = source["name"];
	        this.datatype = this.convertValues(source["datatype"], Type);
	        this.default = source["default"];
	        this.is_primary = source["is_primary"];
	        this.is_sequence = source["is_sequence"];
	        this.const_value = source["const_value"];
	        this.interpolate = source["interpolate"];
	        this.join = source["join"];
	        this.comment = source["comment"];
	    }
	
		convertValues(a: any, classs: any, asMap: boolean = false): any {
		    if (!a) {
		        return a;
		    }
		    if (a.slice && a.map) {
		        return (a as any[]).map(elem => this.convertValues(elem, classs));
		    } else if ("object" === typeof a) {
		        if (asMap) {
		            for (const key of Object.keys(a)) {
		                a[key] = new classs(a[key]);
		            }
		            return a;
		        }
		        return new classs(a);
		    }
		    return a;
		}
	}
	export class Enum {
	    name?: string;
	    values?: Field[];
	
	    static createFrom(source: any = {}) {
	        return new Enum(source);
	    }
	
	    constructor(source: any = {}) {
	        if ('string' === typeof source) source = JSON.parse(source);
	        this.name = source["name"];
	        this.values = this.convertValues(source["values"], Field);
	    }
	
		convertValues(a: any, classs: any, asMap: boolean = false): any {
		    if (!a) {
		        return a;
		    }
		    if (a.slice && a.map) {
		        return (a as any[]).map(elem => this.convertValues(elem, classs));
		    } else if ("object" === typeof a) {
		        if (asMap) {
		            for (const key of Object.keys(a)) {
		                a[key] = new classs(a[key]);
		            }
		            return a;
		        }
		        return new classs(a);
		    }
		    return a;
		}
	}
	
	export class FileTree {
	    dir: string;
	    path: string;
	    name: string;
	    size: number;
	    // Go type: time
	    mod_time: any;
	    is_dir: boolean;
	    children: FileTree[];
	
	    static createFrom(source: any = {}) {
	        return new FileTree(source);
	    }
	
	    constructor(source: any = {}) {
	        if ('string' === typeof source) source = JSON.parse(source);
	        this.dir = source["dir"];
	        this.path = source["path"];
	        this.name = source["name"];
	        this.size = source["size"];
	        this.mod_time = this.convertValues(source["mod_time"], null);
	        this.is_dir = source["is_dir"];
	        this.children = this.convertValues(source["children"], FileTree);
	    }
	
		convertValues(a: any, classs: any, asMap: boolean = false): any {
		    if (!a) {
		        return a;
		    }
		    if (a.slice && a.map) {
		        return (a as any[]).map(elem => this.convertValues(elem, classs));
		    } else if ("object" === typeof a) {
		        if (asMap) {
		            for (const key of Object.keys(a)) {
		                a[key] = new classs(a[key]);
		            }
		            return a;
		        }
		        return new classs(a);
		    }
		    return a;
		}
	}
	export class ForeignKey {
	    name?: string;
	    column?: Field[];
	    ref_table?: string;
	    ref_column?: Field[];
	
	    static createFrom(source: any = {}) {
	        return new ForeignKey(source);
	    }
	
	    constructor(source: any = {}) {
	        if ('string' === typeof source) source = JSON.parse(source);
	        this.name = source["name"];
	        this.column = this.convertValues(source["column"], Field);
	        this.ref_table = source["ref_table"];
	        this.ref_column = this.convertValues(source["ref_column"], Field);
	    }
	
		convertValues(a: any, classs: any, asMap: boolean = false): any {
		    if (!a) {
		        return a;
		    }
		    if (a.slice && a.map) {
		        return (a as any[]).map(elem => this.convertValues(elem, classs));
		    } else if ("object" === typeof a) {
		        if (asMap) {
		            for (const key of Object.keys(a)) {
		                a[key] = new classs(a[key]);
		            }
		            return a;
		        }
		        return new classs(a);
		    }
		    return a;
		}
	}
	export class Index {
	    name?: string;
	    fields?: Field[];
	    is_unique?: boolean;
	    is_primary?: boolean;
	
	    static createFrom(source: any = {}) {
	        return new Index(source);
	    }
	
	    constructor(source: any = {}) {
	        if ('string' === typeof source) source = JSON.parse(source);
	        this.name = source["name"];
	        this.fields = this.convertValues(source["fields"], Field);
	        this.is_unique = source["is_unique"];
	        this.is_primary = source["is_primary"];
	    }
	
		convertValues(a: any, classs: any, asMap: boolean = false): any {
		    if (!a) {
		        return a;
		    }
		    if (a.slice && a.map) {
		        return (a as any[]).map(elem => this.convertValues(elem, classs));
		    } else if ("object" === typeof a) {
		        if (asMap) {
		            for (const key of Object.keys(a)) {
		                a[key] = new classs(a[key]);
		            }
		            return a;
		        }
		        return new classs(a);
		    }
		    return a;
		}
	}
	export class Proc {
	    type?: string;
	    name?: string;
	    params?: Field[];
	    return?: Field[];
	    void?: boolean;
	    definition?: string;
	
	    static createFrom(source: any = {}) {
	        return new Proc(source);
	    }
	
	    constructor(source: any = {}) {
	        if ('string' === typeof source) source = JSON.parse(source);
	        this.type = source["type"];
	        this.name = source["name"];
	        this.params = this.convertValues(source["params"], Field);
	        this.return = this.convertValues(source["return"], Field);
	        this.void = source["void"];
	        this.definition = source["definition"];
	    }
	
		convertValues(a: any, classs: any, asMap: boolean = false): any {
		    if (!a) {
		        return a;
		    }
		    if (a.slice && a.map) {
		        return (a as any[]).map(elem => this.convertValues(elem, classs));
		    } else if ("object" === typeof a) {
		        if (asMap) {
		            for (const key of Object.keys(a)) {
		                a[key] = new classs(a[key]);
		            }
		            return a;
		        }
		        return new classs(a);
		    }
		    return a;
		}
	}
	export class Query {
	    driver?: string;
	    name?: string;
	    comment?: string;
	    exec?: boolean;
	    flat?: boolean;
	    one?: boolean;
	    interpolate?: boolean;
	    type?: string;
	    type_comment?: string;
	    fields?: Field[];
	    manual_fields?: boolean;
	    params?: Field[];
	    query?: string[];
	    comments?: string[];
	    rows?: any[];
	
	    static createFrom(source: any = {}) {
	        return new Query(source);
	    }
	
	    constructor(source: any = {}) {
	        if ('string' === typeof source) source = JSON.parse(source);
	        this.driver = source["driver"];
	        this.name = source["name"];
	        this.comment = source["comment"];
	        this.exec = source["exec"];
	        this.flat = source["flat"];
	        this.one = source["one"];
	        this.interpolate = source["interpolate"];
	        this.type = source["type"];
	        this.type_comment = source["type_comment"];
	        this.fields = this.convertValues(source["fields"], Field);
	        this.manual_fields = source["manual_fields"];
	        this.params = this.convertValues(source["params"], Field);
	        this.query = source["query"];
	        this.comments = source["comments"];
	        this.rows = source["rows"];
	    }
	
		convertValues(a: any, classs: any, asMap: boolean = false): any {
		    if (!a) {
		        return a;
		    }
		    if (a.slice && a.map) {
		        return (a as any[]).map(elem => this.convertValues(elem, classs));
		    } else if ("object" === typeof a) {
		        if (asMap) {
		            for (const key of Object.keys(a)) {
		                a[key] = new classs(a[key]);
		            }
		            return a;
		        }
		        return new classs(a);
		    }
		    return a;
		}
	}
	export class Table {
	    type?: string;
	    name?: string;
	    columns?: Field[];
	    primary_keys?: Field[];
	    indexes?: Index[];
	    foreign_keys?: ForeignKey[];
	    manual?: boolean;
	    definition?: string;
	
	    static createFrom(source: any = {}) {
	        return new Table(source);
	    }
	
	    constructor(source: any = {}) {
	        if ('string' === typeof source) source = JSON.parse(source);
	        this.type = source["type"];
	        this.name = source["name"];
	        this.columns = this.convertValues(source["columns"], Field);
	        this.primary_keys = this.convertValues(source["primary_keys"], Field);
	        this.indexes = this.convertValues(source["indexes"], Index);
	        this.foreign_keys = this.convertValues(source["foreign_keys"], ForeignKey);
	        this.manual = source["manual"];
	        this.definition = source["definition"];
	    }
	
		convertValues(a: any, classs: any, asMap: boolean = false): any {
		    if (!a) {
		        return a;
		    }
		    if (a.slice && a.map) {
		        return (a as any[]).map(elem => this.convertValues(elem, classs));
		    } else if ("object" === typeof a) {
		        if (asMap) {
		            for (const key of Object.keys(a)) {
		                a[key] = new classs(a[key]);
		            }
		            return a;
		        }
		        return new classs(a);
		    }
		    return a;
		}
	}
	export class Schema {
	    type?: string;
	    name?: string;
	    enums?: Enum[];
	    procs?: Proc[];
	    tables?: Table[];
	    views?: Table[];
	
	    static createFrom(source: any = {}) {
	        return new Schema(source);
	    }
	
	    constructor(source: any = {}) {
	        if ('string' === typeof source) source = JSON.parse(source);
	        this.type = source["type"];
	        this.name = source["name"];
	        this.enums = this.convertValues(source["enums"], Enum);
	        this.procs = this.convertValues(source["procs"], Proc);
	        this.tables = this.convertValues(source["tables"], Table);
	        this.views = this.convertValues(source["views"], Table);
	    }
	
		convertValues(a: any, classs: any, asMap: boolean = false): any {
		    if (!a) {
		        return a;
		    }
		    if (a.slice && a.map) {
		        return (a as any[]).map(elem => this.convertValues(elem, classs));
		    } else if ("object" === typeof a) {
		        if (asMap) {
		            for (const key of Object.keys(a)) {
		                a[key] = new classs(a[key]);
		            }
		            return a;
		        }
		        return new classs(a);
		    }
		    return a;
		}
	}
	

}

